package com.itheima.controller;

import com.itheima.health.entity.Result;
import com.itheima.health.service.OrderSettingService;
import com.itheima.health.utils.poi.POIUtils;
//import org.apache.dubbo.config.annotation.Reference;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

/**
 * @program: health_paret
 * @description:
 * @author: Mr.Wang
 * @create: 2020-11-09 13:00
 **/
@RestController
@RequestMapping("ordersetting")
public class OrderSettingWeb {
    //@Reference
    //private CheckGroupService checkGroupService;
    //@Autowired
    //private RedisTemplate redisTemplate;
    @Reference
    private OrderSettingService orderSettingService;

    //进行修改当天最大预约数
    @PutMapping("updateNumberByOrderdate/{number}/{settingDay}")
    public Result updateNumberInfoOrderSetting(@PathVariable("number")int number,@PathVariable("settingDay")String settingDay) {
        Boolean xxx = orderSettingService.updateNumberInfoOrderSetting(number,settingDay);
        return new Result(xxx);
    }
    //文件上传
    @PostMapping("importOrderSettings")
    public Result upload(@RequestParam("excelFile") MultipartFile multipartFile) {
        try {
            List<String[]> strings = POIUtils.readExcel(multipartFile);
            orderSettingService.batchOrdeiSetting(strings);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new Result(true);
    }

    //显示页面上日历上的预约数量
    @GetMapping("findSettingData/{year}/{month}")
    public Result findSettingDate(@PathVariable("year") int year, @PathVariable("month") int month) {
        Map settingDate = orderSettingService.findSettingDate(year, month);
        return new Result(true, "查询失败", settingDate);
    }
}
